<%--
  Created by IntelliJ IDEA.
  User: 24646
  Date: 2024/11/7
  Time: 17:34
  To change this template use File | Settings | File Templates.
--%>

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://www.springframework.org/tags" prefix="spring" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<html>
<head>
    <title>Book List</title>
    <style>
        body {
            background-color: #e0e7ff;
            font-family: Arial, sans-serif;
            margin: 0;
            padding: 20px;
        }
        h2 {
            color: #333;
            text-align: center;
        }
        .search-form {
            display: flex;
            justify-content: center;
            margin-bottom: 20px;
        }
        input[type="search"] {
            padding: 10px;
            border: 1px solid #ccc;
            border-radius: 4px;
            margin-right: 10px;
            width: 300px;
            font-size: 16px;
        }
        button {
            background-color: #4a90e2;
            color: white;
            border: none;
            padding: 10px 15px;
            border-radius: 4px;
            cursor: pointer;
            font-size: 16px;
        }
        button:hover {
            background-color: #357ab8;
        }
        table {
            width: 100%;
            border-collapse: collapse;
            margin-top: 20px;
        }
        th, td {
            padding: 12px;
            text-align: left;
            border: 1px solid #ccc;
        }
        th {
            background-color: #4a90e2;
            color: white;
        }
        tr:nth-child(even) {
            background-color: #f2f2f2;
        }
        tr:hover {
            background-color: #d1e7ff;
        }
        img {
            width: 100px;
            height: auto;
        }
        a {
            text-decoration: none;
            color: #4a90e2;
            margin-right: 10px;
        }
        a:hover {
            text-decoration: underline;
        }
        .add-book-button {
            display: block;
            margin: 20px auto;
            text-align: center;
        }
    </style>
</head>
<body>

<h2>Hello, ${sessionScope.get("user").username}</h2>

<div class="search-form">
    <form method="get" action="${pageContext.request.contextPath}/book/searchLike">
        <input type="search" name="name" placeholder="请输入你想要搜索的书籍"/>
        <button type="submit">提交</button>
    </form>
</div>

<div class="add-book-button">
    <a href="${pageContext.request.contextPath}/book/PreInsertBook">
        <button type="button">添加图书</button>
    </a>
</div>

<table>
    <tr>
        <th>图书id</th>
        <th>图书图片</th>
        <th>图书名称</th>
        <th>出版社</th>
        <th>作者</th>
        <th>出版时间</th>
        <th>操作</th>
    </tr>
    <c:forEach var="item" items="${books}">
        <tr>
            <td>${item.id}</td>
            <td><img src="/images/${item.image}" alt="Example Image"/></td>
            <td>${item.name}</td>
            <td>${item.press}</td>
            <td>${item.author}</td>
            <td><fmt:formatDate value="${item.updatetime}" pattern="yyyy-MM-dd" /></td>
            <td>
                <a href="${pageContext.request.contextPath}/book/update?id=${item.id}">修改</a>
                <a href="${pageContext.request.contextPath}/book/delete?id=${item.id}">删除</a>
            </td>
        </tr>
    </c:forEach>
</table>
</body>
</html>